package com.jrh.dal;

import java.util.List;

import com.jrh.domain.entity.Category;

/**
 * 类目DAO
 * 
 * @author jasen.hsu.cn@gmail.com 2012-7-16 下午2:01:24
 */
public class CategoryDao extends BaseDao<Category> {

    public CategoryDao(){
        this.namespace = "jrh.single.category";
    }

    /**
     * 取得所有父类目
     * 
     * @return
     */
    @SuppressWarnings("unchecked")
    public List<Category> listParentCategory() {
        return (List<Category>) sqlMapClientTemplate.queryForList(namespace + "." + "listParentCategory");
    }

    /**
     * 取得所有类目数据
     * 
     * @return
     */
    @SuppressWarnings("unchecked")
    public List<Category> listAllCategory() {
        return (List<Category>) sqlMapClientTemplate.queryForList(namespace + "." + "listAllCategory");
    }

    /**
     * 根据品牌取得所有类目数据
     * 
     * @param brandId
     * @return
     */
    @SuppressWarnings("unchecked")
    public List<Category> listAllCategoryByBrand(Long brandId) {
        return (List<Category>) sqlMapClientTemplate.queryForList(namespace + "." + "listAllCategoryByBrand", brandId);
    }

    /**
     * 根据父类code取得所有子类
     * 
     * @param parentCode 父类code
     * @return
     */
    @SuppressWarnings("unchecked")
    public List<Category> listChildCategory(Long parent) {
        return (List<Category>) sqlMapClientTemplate.queryForList(namespace + "." + "listChildCategory", parent);
    }

}
